/*
*			»ù±¾Ïß³Ì³éÏóÀà,¶¥²ã°ü
*/
#pragma once


#include <boost/noncopyable.hpp>

#include <boost/thread.hpp>

#include "CxType.h"

using boost::noncopyable;
using boost::thread;

/*
*		³éÏóÏß³ÌÀà£¬´´½¨¶ÔÏó¼´¿ªÊ¼Ïß³Ì
*/
class	  CxThread : public		noncopyable 
{
public:

	virtual		~CxThread(){}

	CxThread():m_state(THREAD_RUNNING)
	{
		m_thread=thread(boost::bind<void>(&CxThread::ThreadFunc,this));
	}

	//Ïß³Ì¿ªÊ¼º¯Êý£¬Èç¹ûÐèÒªÔÚ×ÓÀàÖÐÊ¹ÓÃÐèÅäºÏÌõ¼þ±äÁ¿
	virtual		void		Start()=0;

	//Ïß³Ì½áÊøº¯Êý£¬×ÓÀàÖÐÐèÒªÊ¹ÓÃÐèÒªÅäºÏÏß³ÌÖÐ¶ÏÒì³£.
	virtual		void		Close()=0;

	virtual		UINT		GetState()const=0;

protected:

	//Ïß³ÌÔËÐÐº¯Êý£¬Í¨¹ýÖØÔØÊ¹ÔËÐÐÏß³Ì²»Í¬
	virtual		void		RunFunc()=0;	
	//Ïß³ÌÊµ¼Êº¯Êý
    static		void		ThreadFunc(CxThread *);

protected:
	//Ïß³Ì²Ù×÷¾ä±ú
	thread						m_thread;
	//Ïß³Ì×´Ì¬
	UINT						m_state;
};
